<?php
require_once 'buildCurl.php';
$res = json_decode(file_get_contents('php://input'), true);

$session = $res['session'];
$url = "http://211.82.48.36/student/integratedQuery/scoreQuery/allPassingScores/index";

$myCurl = new MyCurl($url, $session);
$result = $myCurl->getResult();
$httpCode = $myCurl->getHttpCode();

if ($httpCode != 200) {
    $arr = array('err' => 1);
    exit(json_encode($arr));
}

$result = explode('scoreQuery', $result, 13)[9];
$result = explode('allPassingScores', $result, 2)[0];


$url = "http://211.82.48.36/student/integratedQuery/scoreQuery" . $result . "allPassingScores/callback";

$myCurl = new MyCurl($url, $session);
$result = $myCurl->getResult();
$httpCode = $myCurl->getHttpCode();


if ($httpCode != 200) {
    $arr = array('err' => 1);
    exit(json_encode($arr));
}

$content = json_decode($result, true);
$list = $content['lnList'];


foreach ($list as $value) {
    $term_name[] = preg_replace('/\(.*?\)/', '', $value['cjlx']);
    $term[] = $value['zxjxjhh'];
}

$arr = array('err' => 0, 'term_name' => $term_name, 'term' => $term, 'all_score' => $content);
exit(json_encode($arr));
